package com.ht.modules.system.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.ht.modules.system.entity.SysUserRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * <p>
 * 用户角色表 Mapper 接口
 * </p>
 *
 *
 * @since 2018-12-21
 */
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {

	@Select("select role_code from sys_role where id in (select role_id from sys_user_role where user_id = (select id from sys_user where username=#{username}))")
	List<String> getRoleByUserName(@Param("username") String username);

	@Select("SELECT b.role_code FROM sys_user_role a JOIN sys_role b ON a.role_id = b.id WHERE a.user_id = #{id}")
	List<String> getRoleCodeByUserId(String id);

	@Select("select  GROUP_CONCAT(sys_role.id) from sys_role where id in (select role_id from sys_user_role where user_id = #{userid})")
	String getRoleIdByUserId(@Param("userid") String userid);

}
